﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
using System.IO;
using System.IO.Compression;
using System.Xml;

namespace watchWeb
{
    class Program
    {
        static void Main(string[] args)
        {
            /*System.Net.WebClient client = new WebClient();
            byte[] page = client.DownloadData("http://www.163.com");
            string content = System.Text.Encoding.UTF8.GetString(page);
            string regex = "href=[\\\"\\\'](http:\\/\\/|\\.\\/|\\/)?\\w+(\\.\\w+)*(\\/\\w+(\\.\\w+)?)*(\\/|\\?\\w*=\\w*(&\\w*=\\w*)*)?[\\\"\\\']";
            Regex re = new Regex(regex);
            MatchCollection matches = re.Matches(content);

            System.Collections.IEnumerator enu = matches.GetEnumerator();
            while (enu.MoveNext() && enu.Current != null)
            {
                Match match = (Match)(enu.Current);
                Console.Write(match.Value + "\r\n");
            }*/
             
            GetConfig getcon = new GetConfig("config.xml");
            foreach (string str in getcon.GetKeyWord())
            {
                Console.WriteLine(str);
            }
            
            return;
            XmlDocument doc=new XmlDocument();
            doc.Load("config.xml");
            XmlElement root = doc.DocumentElement;
            XmlNodeList listNodes = null;
            listNodes = root.SelectNodes("/info/web_info/web");
            foreach (XmlNode node in listNodes )
            {
                Console.WriteLine(node.SelectSingleNode("name").InnerText);
                Console.WriteLine(node.InnerText);
            }
            /*
            foreach(XmlNode xnf in xnl) 
            { 
                XmlElement xe=(XmlElement)xnf;
                Console.WriteLine(xe.GetAttribute("web"));//显示属性值 
                Console.WriteLine(xe.GetAttribute("keyword")); 
                XmlNodeList xnf1=xe.ChildNodes; 
                foreach(XmlNode xn2 in xnf1) 
                { 
                    Console.WriteLine(xn2.InnerText);//显示子节点点文本 
                } 
            }*/
            return;
            /*

            GetHtml html = new GetHtml("http://www.163.com");
            string s="";
            try
            {
                s = html.toHtml();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(s);
            foreach(var script in doc.DocumentNode.Descendants("script").ToArray())
                script.Remove();
            foreach(var style in doc.DocumentNode.Descendants("style").ToArray())
                style.Remove();
            foreach (var comment in doc.DocumentNode.SelectNodes("//comment()").ToArray())
                comment.Remove();//新增的代码
            //Console.WriteLine(doc.DocumentNode.InnerText);
            foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
            {
                Console.WriteLine(link.InnerText);
                Console.WriteLine(link.Attributes["href"].Value.ToString());
            }
            */
        }
    }
}
